<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
  <html>
  <head>
    <style type="text/css">
    table.gridtable {
	    font-family: verdana,arial,sans-serif;
	    font-size:11px;
	    color:#333333;
	    border-width: 1px;
	    border-color: #666666;
	    border-collapse: collapse;
    }
    table.gridtable th {
	    border-width: 1px;
	    padding: 8px;
	    border-style: solid;
	    border-color: #666666;
	    background-color: #dedede;
    }
    table.gridtable td {
	    border-width: 1px;
	    padding: 3px;
	    border-style: solid;
	    border-color: #666666;
	    background-color: #ffffff;
    }
    </style>
  </head>
  <body>
    <h2>OD Master Document - V.<xsl:value-of select="nodes/@major_version"/>.<xsl:value-of select="nodes/@minor_version"/></h2>
    <xsl:for-each select="nodes/node">
        <h3><xsl:value-of select="name"/></h3>
        <table class="gridtable">
          <tr>
            <th>Offset</th>        
            <th>Name</th>
            <th>Description</th>
            <th>Unit</th>
            <th>Datatype</th>
            <th>Value Range</th>
            <th>Update Rate</th>
          </tr>
          <xsl:for-each select="TPDO">
            <tr>
              <td><xsl:value-of select="@nodeindex"/></td>
              <td><xsl:value-of select="PDOName"/></td>
              <td><xsl:value-of select="PDODesc"/></td>
              <td><xsl:value-of select="PDOUnit"/></td>
              <xsl:variable name="lpath" select="PDODataType/@path" />
              <xsl:variable name="lid" select="PDODataType/@id" />
              <td><a href="{$lpath}"><xsl:value-of select="document(string($lpath))//DataType[@id=$lid]/Name"/></a></td>
              <td><xsl:if test="count(PDOValueRange)=1">
                <xsl:value-of select="PDOValueRange/min"/> to <xsl:value-of select="PDOValueRange/max"/>
                </xsl:if>
              </td>
              <td><xsl:value-of select="PDOUpdateRate"/></td>
            </tr>
          </xsl:for-each>
        </table>
    </xsl:for-each>
  </body>
  </html>
</xsl:template>

</xsl:stylesheet>
